package com.fireowlf.springboot;

import java.util.List;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;

@SpringBootApplication
public class FastJsonApplication1 extends WebMvcConfigurerAdapter{
	public static void main(String[] args) {
		SpringApplication.run(FastJsonApplication1.class, args);
	}
	
	@Override
	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
		//1.定义消息转换对象
		FastJsonHttpMessageConverter fastConvertor = new FastJsonHttpMessageConverter();
		//2.添加fastjson的配置消息
		FastJsonConfig fastConf = new FastJsonConfig();
		fastConf.setSerializerFeatures(SerializerFeature.PrettyFormat);//设置让json格式化
		//3.将配置信息添加到转换对象中
		fastConvertor.setFastJsonConfig(fastConf);
		//4.将转换对象加到消息转换队列中
		converters.add(fastConvertor);
	}
}
